/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.erpworld.hr.dao;

import org.erpworld.r.dao.RcinsiyetDAO;
import org.erpworld.r.dao.RilceDAO;

/**
 * @author volkan
 */
public class DAOTest {

    public static void main(String[] args) throws Exception {

        RcinsiyetDAO cDao = new RcinsiyetDAO();
        String[] cinsiyetStrs = new String[cDao.list().size()];
        for (int i = 0; i < cinsiyetStrs.length; i++) {
            cinsiyetStrs[i] = cDao.list().get(i).getAd();
        }
        for (String string : cinsiyetStrs) {
            System.out.println(cinsiyetStrs.toString());
        }
        // Obtain DAOFactory.
// Obtain UserDAO.
//        UserDAO userDAO = new UserDAO();
//        System.out.println("UserDAO successfully obtained: " + userDAO);
//        System.out.println(userDAO.existUsername("volkan"));
//        System.out.println("id "+userDAO.find(8).getUsername());
//        System.out.println("size "+userDAO.list().size());

// Create user.
//        User user = new User("burhshshshdsxcccxxxxxaağın", "sennerdesixczxcnxhhhshcxbxbxvşimdi", "emvxvxazxcccilsgsgsggs@emahshsil.com");
//        userDAO.create(user);
//        System.out.println("User successfully created: " + user);

// Create another user.
//UserDTO anotherUser = new UserDTO(null, "anotherName", "anotherPassword");
//userDAO.save(anotherUser);
//System.out.println("Another User successfully created: " + anotherUser);

        /*
        //Update user.
        
        user.setPassword("newPasswsdffford");
        user.setEmail("foo@bafdsr.com");
        userDAO.update(user);
        System.out.println("User successfully updated: " + user);
        
        // List all users.
        List<User> users = userDAO.list();
        System.out.println("List of users successfully queried: " + users);
        System.out.println("Thus, amount of users in database is: " + users.size());
        
        // Delete user.
        User user=userDAO.find(84l);
        userDAO.delete(user);
        System.out.println("user successfully deleted: " + user);
        /*
        // Get another user by name and password.
        user foundAnotherUser = userDAO.find("anotherName", "anotherPassword");
        System.out.println("Another user successfully queried: " + foundAnotherUser);
        
        // Delete another user.
        userDAO.delete(foundAnotherUser);
        System.out.println("Another user successfully deleted: " + foundAnotherUser);
        
        // List all users.
        users = userDAO.list();
        System.out.println("List of users successfully queried: " + users);
        System.out.println("Thus, amount of users in database is: " + users.size());*/
        /*    org.hibernate.Session ses = HibernateSessionFactory.getSession();
        
        System.out.println("Session" + ses.getTransaction().isActive());
        ses.getTransaction().begin();
        System.out.println("Session" + ses.getTransaction().isActive());
        
        Logger logger = LoggerFactory.getLogger(DAOTest.class);
        logger.info("Hello World");
        logger.error("Hata Patladı"); */

    }
}
